package proj.pt.services;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class Role {
	
	private String id;
	private String name;
	
	public static final String ROLE_ADMIN_FULL_ACCESS = "ROLE_ADMIN_FULL_ACCESS";
	public static final String ROLE_ADMIN_VIEW_ONLY = "ROLE_ADMIN_VIEW_ONLY";
	public static final String ROLE_HOD_FULL_ACCESS = "ROLE_HOD_FULL_ACCESS";
	public static final String ROLE_HOD_VIEW_ONLY = "ROLE_HOD_VIEW_ONLY";
	public static final String ROLE_TUTOR_FULL_ACCESS = "ROLE_TUTOR_FULL_ACCESS";
	public static final String ROLE_TUTOR_VIEW_ONLY = "ROLE_TUTOR_VIEW_ONLY";
	public static final String ROLE_STUDENT_FULL_ACCESS = "ROLE_STUDENT_FULL_ACCESS";
	public static final String ROLE_STUDENT_VIEW_ONLY = "ROLE_STUDENT_VIEW_ONLY";
	
	private static final String ROLE_ADMIN_FULL_ACCESS_NAME = "Admin Full Access";
	private static final String ROLE_ADMIN_VIEW_ONLY_NAME = "Admin View Only";
	private static final String ROLE_HOD_FULL_ACCESS_NAME = "HOD Full Access";
	private static final String ROLE_HOD_VIEW_ONLY_NAME = "HOD View Only";
	private static final String ROLE_TUTOR_FULL_ACCESS_NAME = "Tutor Full Access";
	private static final String ROLE_TUTOR_VIEW_ONLY_NAME = "Tutor View Only";
	private static final String ROLE_STUDENT_FULL_ACCESS_NAME = "Student Full Access";
	private static final String ROLE_STUDENT_VIEW_ONLY_NAME = "Student View Only";
	
	private static List roles = new ArrayList();
	static {
		roles.add(createRole(ROLE_ADMIN_FULL_ACCESS, ROLE_ADMIN_FULL_ACCESS_NAME));
		roles.add(createRole(ROLE_ADMIN_VIEW_ONLY, ROLE_ADMIN_VIEW_ONLY_NAME));
		roles.add(createRole(ROLE_HOD_FULL_ACCESS, ROLE_HOD_FULL_ACCESS_NAME));
		roles.add(createRole(ROLE_HOD_VIEW_ONLY, ROLE_HOD_VIEW_ONLY_NAME));
		roles.add(createRole(ROLE_TUTOR_FULL_ACCESS, ROLE_TUTOR_FULL_ACCESS_NAME));
		roles.add(createRole(ROLE_TUTOR_VIEW_ONLY, ROLE_TUTOR_VIEW_ONLY_NAME));
		roles.add(createRole(ROLE_STUDENT_FULL_ACCESS, ROLE_STUDENT_FULL_ACCESS_NAME));
		roles.add(createRole(ROLE_STUDENT_VIEW_ONLY, ROLE_STUDENT_VIEW_ONLY_NAME));
	}
	
	private static Role createRole(String id, String name){
		Role role = new Role();
		role.id = id;
		role.name = name;
		return role;
	}
	public static List getRoles(){
		return roles;
	}
	public static Map getRoleMap(){
		Map map = new HashMap();
		Role role;
		for(int intx = 0; intx < roles.size(); intx++){
			role = (Role)roles.get(intx);
			map.put(role.getId(), role.getName());
		}
		return map;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public static Map getAdminRoles(){
		Map roles = new HashMap();
		roles.put(ROLE_ADMIN_FULL_ACCESS, ROLE_ADMIN_FULL_ACCESS_NAME);
		roles.put(ROLE_ADMIN_VIEW_ONLY, ROLE_ADMIN_VIEW_ONLY_NAME);
		return roles;
	}
	
	public static Map getStaffRoles(){
		Map roles = new HashMap();
		roles.put(ROLE_HOD_FULL_ACCESS, ROLE_HOD_FULL_ACCESS_NAME);
		roles.put(ROLE_HOD_VIEW_ONLY, ROLE_HOD_VIEW_ONLY_NAME);
		roles.put(ROLE_TUTOR_FULL_ACCESS, ROLE_TUTOR_FULL_ACCESS_NAME);
		roles.put(ROLE_TUTOR_VIEW_ONLY, ROLE_TUTOR_VIEW_ONLY_NAME);
		return roles;
	}
	
	public static Map getStudentRoles(){
		Map roles = new HashMap();
		roles.put(ROLE_STUDENT_FULL_ACCESS, ROLE_STUDENT_FULL_ACCESS_NAME);
		roles.put(ROLE_STUDENT_VIEW_ONLY, ROLE_STUDENT_VIEW_ONLY_NAME);
		return roles;
	}
	
	public static Map getHODRoles(){
		Map roles = new HashMap();
		roles.put(ROLE_HOD_FULL_ACCESS, ROLE_HOD_FULL_ACCESS_NAME);
		roles.put(ROLE_HOD_VIEW_ONLY, ROLE_HOD_VIEW_ONLY_NAME);
		return roles;
	}
	
	public static Map getTutorRoles(){
		Map roles = new HashMap();
		roles.put(ROLE_TUTOR_FULL_ACCESS, ROLE_TUTOR_FULL_ACCESS_NAME);
		roles.put(ROLE_TUTOR_VIEW_ONLY, ROLE_TUTOR_VIEW_ONLY_NAME);
		return roles;
	}
	
}
